package com.kk.springboot_002.mapper;

import com.kk.springboot_002.pojo.Fruit;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface FruitMapper {
    /**
     * 根据水果名称和用户id查询水果
     * @param fruitName
     * @param id
     * @return
     */
    @Select("select * from fruit where fruit_name = #{fruitName} and user_id = #{id}")
    Fruit findFruitByNameAndUserId(String fruitName, Integer id);

    /**
     * 添加水果
     * @param fruitName
     * @param id
     */
    @Insert("insert into fruit(fruit_name, user_id) values(#{fruitName}, #{id})")
    void addFruit(String fruitName, Integer id);

    /**
     * 根据用户id查询水果
     * @param id
     */
    @Select("select * from fruit where user_id = #{id}")
    List<Fruit> findFruitByUserId(Integer id);
}
